<?php

$host = "localhost";
$user = "root";
$pass = "";

/**
 * @brief Disconnect from database
 * @return integer 0: successful
 */
function disconnect()
{
  mysql_close();
  return 0;
}

/**
 * @brief Execute a query
 * @param string $Query_String the query to be executed
 * @return integer Current result if succesful and null if failed
 */
function query($Query_String)
{
  $host = "localhost";
  $user = "root";
  $pass = "";
  $db = "db_web";

  $r = mysql_connect($host, $user, $pass);
  $r2 = mysql_select_db($db);

  $query = $Query_String;

  $rs = mysql_query($query);

  if (!$rs) {
    return NULL;
  } else {
    return $rs;
  }
}

/**
 * @brief Number of fields in current row
 * @param $rs mssql query
 * @return integer number of fields
 */
function num_fields($rs)
{
  return mysql_num_fields($rs);
}

/**
 * @brief Number of rows in current result set
 * @param $rs mssql query
 * @return integer number of rows
 */
function num_rows($rs)
{
  return mysql_num_rows($rs);
}

?>